//
//  MBRecordCell.m
//  MiBaoTu
//
//  Created by 彭鹏 on 16/9/21.
//  Copyright © 2016年 com.caesartech15. All rights reserved.
//

#import "MBRecordCell.h"

@implementation MBRecordCell
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identify = @"MBRecordCell";
    MBRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:identify];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"MBRecordCell" owner:self options:nil] lastObject];
    }
    return cell;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    //value
    if (!_dateDic) return;
    
    NSString *imgPath = [_dateDic objectForKey:@"PicPath"];
    if (![imgPath isKindOfClass:[NSNull class]]) {
        [_iconImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",MUSIC_PLAY_Url,imgPath]] placeholderImage:[UIImage imageNamed:@"qzx_player_icon"]];
    } else {
        _iconImageView.image = [UIImage imageNamed:@"qzx_player_icon"];
    }
    _iconImageView.layer.cornerRadius = 5.;
    _iconImageView.layer.masksToBounds = YES;
    
    NSString *audioName = [_dateDic objectForKey:@"RecordName"];
    if (audioName.length > 0) {
        audioName = [audioName componentsSeparatedByString:@"."][0];
        _titleLb.text = [NSString stringWithFormat:@"%@",audioName];
    }
    
    NSString *RecordNum = [NSString stringWithFormat:@"%@",[_dateDic objectForKey:@"RecordNum"]];
    if (RecordNum.length > 0) {
        _countLb.text = [NSString stringWithFormat:@"%@人在录制",[RecordNum getValues]];
    }
}

- (IBAction)onRecordQinZiXiuAction:(id)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(onSelectItemForRecordQinZiXiu:)]) {
        [_delegate onSelectItemForRecordQinZiXiu:_dateDic];
    }
}
@end
